/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package probando;

/**
 *
 * @author Administrador
 */
public class ThreadA {
public ThreadA() {
}

public static void main(String[] args)
{
ThreadB b = new ThreadB();
b.start();

synchronized(b){
try {
System.out.println("Esperando a que B se complete...");
b.wait();
} catch (InterruptedException ex) { }

System.out.println("Total:" +b.total);
}
}
}

class ThreadB extends Thread{
long total;

public void run(){
synchronized(this)
{
for(long i=0; i<1000000000;i++)
total+=i;
notify();
}

}
}
